import { _decorator, Component, instantiate, Label, Layout, Node, ScrollView, Slider, Sprite, Toggle, Vec2, Vec3 } from 'cc';
import { UIManager } from '../UIManager';
import { LanauageManager } from '../LanauageManager';
import { GameData } from '../GameData';
import { HttpClient } from '../net/HttpClient';
import { EventManager } from '../EventManager';
import { AudioMgr } from '../AudioMgr';
const { ccclass, property } = _decorator;

@ccclass('popupInviteHistory')
export class popupInviteHistory extends Component {

    @property(ScrollView)
    scrollView:ScrollView = null;

    history:string[];

    onEnable() {
        // this.refresh();

        HttpClient.getInstance().sendGetInviteLog((data)=>{
            this.history = data.data.logs;
            this.refresh();
        })
    }

    refresh(){

        for (let index = 0; index < this.scrollView.content.children.length; index++) {
            const element = this.scrollView.content.children[index];
            element.active = false;
        }

        for (let index = 0; index < this.history.length; index++) {
            let des:string = this.history[index];
            let item = this.scrollView.content.children[index];
            if (!item){
                item = instantiate(this.scrollView.content.children[0])
                item.parent = this.scrollView.content;
            }
            item.active = true;
            item.getChildByName("desLab").getComponent(Label).string = des;
        }

    }

    onClickHandler(event:Event, str:string){
        if (str == "getReward"){

        }
    }
}

